<div>
<?php
$this->addScript(array(
	'/js/lib/ckeditor/ckeditor.js',
	'/js/lib/ckeditor/adapters/jquery.js',
	'/js/editArticle.js'
));
$list = $this->getData('list');
$albums = $this->getData('albums');
?>
	<h1><?=$this->T('Edit article')?></h1>
		<?php 
		$l = \App::getLang();
		$a = $list[$l];
		$c = $a->getContent();
		?>
<form class="article-form" enctype="multipart/form-data" method="POST" action="add_article">
	<fieldset class="span6 form-horizontal" >
		<div class="control-group">
			<label class="control-label" for="inputPath"><?=$this->T('Path')?></label>
			<div class="controls">
				<input name='path' type="text" id="inputPath" placeholder="Path" value="<?=$c->getPath()?>" />
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputGroup"><?=$this->T('Article group')?></label>
			<div class="controls">
				<select name="group_id" id="inputGroup">
					<option value="0"<?=($a->getGroupId()==$a::GROUP_BLOG ? ' selected="true"' : '')?>><?=$this->T('Blog')?></option>
					<option value="-1"<?=($a->getGroupId()==$a::GROUP_SYSTEM ? ' selected="true"' : '')?>><?=$this->T('System')?></option>
				</select>
			</div>
		</div>
	</fieldset>
	<fieldset class="span6 form-horizontal">
		<div class="control-group">
			<label class="control-label" for="inputStatus"><?=$this->T('Status')?></label>
			<div class="controls">
				<select name="status_id" id="inputStatus">
					<option value="1" <?=($a->getStatusId()==$a::ACTIVE ? ' selected="true"' : '')?>><?=$this->T('Active')?></option>
					<option value="0"<?=($a->getStatusId()==$a::HIDDEN ? ' selected="true"' : '')?>><?=$this->T('Hidden')?></option>
					<option value="-1"<?=($a->getStatusId()==$a::DELETED ? ' selected="true"' : '')?>><?=$this->T('Deleted')?></option>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="inputStatus"><?=$this->T('Select album')?></label>
			<div class="controls">
				<select name="album_id" id="inputAlbum">
					<option value=''><?=$this->T('No album')?></option>
				<?php foreach ($albums as $al) {?>
					<option value="<?=$al->getObjectId()?>" <?=($al->getObjectId()== $a->getAlbumId() ? ' selected="true"' : '')?>><?=$al->getName()?> (<?=$al->getPhotoCount()?>)</option>
				<?php }?>
				</select>
			</div>
		</div>
	</fieldset>
	<fieldset class="span12">
		<div class="control-group">
			<label class="control-label" for="inputTitle"><?=$this->T('Title')?></label>
			<div class="controls">
				<input class="span12" name='title' type="text" id="inputTitle" placeholder="Title" value="<?=$c->getTitle()?>" />
			</div>
		</div>
	</fieldset>
	<fieldset class="span12">
		<div class="control-group">
			<label class="control-label" for="inputAnnotation"><?=$this->T('Annotation')?></label>
			<div class="controls">
				<textarea class='wysiwyg' name='annotation' id="inputAnnotation" placeholder="Annotation"><![CDATA[ <?=$c->getAnnotation() ?> ]]></textarea>
			</div>
		</div>
		  
		<div class="control-group">
			<label class="control-label" for="inputContent"><?=$this->T('Text')?></label>
			<div class="controls">
				<textarea class='wysiwyg' name='content' id="inputContent" placeholder="Content"><![CDATA[ <?=$c->getContent()?> ]]></textarea>
			</div>
		</div>
	</fieldset>
	
	<input type="hidden" name="language_code" value="<?=$c->getLanguageCode()?>" />
	<input type="hidden" name="article_id" value="<?=$a->getId()?>" />
	<input type="hidden" name="author_id" value="<?=$a->getAuthor()->getId()?>" />
	<div class="form-actions span12">
		<button type="button" class="btn btn-primary" action="apply"><?=$this->T('Apply')?></button>
		<button type="button" class="btn" action="save"><?=$this->T('Save')?></button>
		<button type="button" class="btn" action="revert"><?=$this->T('Revert')?></button>
		<button type="button" class="btn" action="cancel"><?=$this->T('Cancel')?></button>
	</div>
</form>
</div>